/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import javax.persistence.*;

/**
 *
 * @author James
 */
@Entity
@NamedQueries({
  @NamedQuery(name="vFile.findAll",
              query="SELECT e FROM vFile e"),
  @NamedQuery(name="vFile.findByPK",
              query="SELECT e FROM vFile e WHERE e.id = :ID_FILE"),
  @NamedQuery(name="vfile.findByName",
              query="SELECT e FROM vFile e WHERE e.fname = :fname"),
  @NamedQuery(name="vFile.findAllinFolder",
              query="SELECT e FROM vFile e WHERE e.folder = :FOLDER"),
 @NamedQuery(name="vFile.pesquisa",
              query="SELECT e FROM vFile e WHERE e.fname like :PESQUISA"),
 @NamedQuery(name="vFile.findAllinFolderr",
              query="SELECT e FROM vFile e WHERE e.folder = :FOLDER")
 
})
public class vFile implements Serializable {
    @Column(length = 255)
    private String flocation;
    @Column(length = 255)
    private String description;
    @Column(length = 50)
    private String fname;
    @Column
    private int fsize;
    @Column
    private int fowner;
    public vFile()
    {
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @JoinColumn
    @ManyToOne
    private vFolder folder;

    public vFolder getFolder() {
        return folder;
    }

    public void setFolder(vFolder folder) {
        this.folder = folder;
    }

    @ManyToOne
    private Res res;

    public Res getRes() {
        return res;
    }

    public void setRes(Res res) {
        this.res = res;
    }


    @ManyToMany
    private List<Tagg> tag;

    public void addTag(Tagg e){
        tag.add(e);
    }

    public List<Tagg> getTagList()
    {
        return tag;
    }



    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="ID_FILE")
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public vFile(String flocation, String fname,int fowner,int fsize )
    {
        this.flocation = flocation;
        this.fname = fname;
        this.fowner = fowner;
        this.fsize = fsize;
        tag = new ArrayList();

    }
    public vFile(String flocation, String fname,int fowner,int fsize,String description )
    {
        this.flocation = flocation;
        this.fname = fname;
        this.fowner = fowner;
        this.fsize = fsize;
        this.description=description;
        tag = new ArrayList();

    }

    public String getFlocation() {
        return flocation;
    }

    public String getFname() {
        return fname;
    }

    public int getFowner() {
        return fowner;
    }
    public int getFsize() {
        return fsize;
    }

    public void setFlocation(String flocation) {
        this.flocation = flocation;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public void setFowner(int fowner) {
        this.fowner = fowner;
    }

    public void setFsize(int fsize) {
        this.fsize = fsize;
    }




    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof vFile)) {
            return false;
        }
        vFile other = (vFile) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.File[id=" + id + "]";
    }

}


